import React from 'react'
import { Divider } from 'antd'
import { LwjTable } from "components";
import moment from 'moment';
import LwjTable2 from 'components/LwjTable/LwjTable'
import { LwjButton } from "components";
import { receiptType } from 'utils/enumConfig'

const List = ({
  onShowDetail,
  onShowAudit,
  showAuditButton,
  ...tableProps
}) => {
  const columns = [
    {
      title: '收款单号',
      dataIndex: 'num',
      key: 'num',
      width: "5%",
    },
    //  {
    //   title: '类型',
    //   dataIndex: 'receiptType',
    //   key: 'receiptType',
    //   width: "5%",
    //   render: (text, record) => (
    //     <span >
    //       {receiptType[record.receiptType]}
    //     </span >
    //   )
    // },
     {
      title: '应收金额(元)',
      dataIndex: 'receivable',
      key: 'receivable',
      align: "right",
      width: "5%",
      render: (text, record, index) => (record.receivable.toFixed(2))
    }, {
      title: '实收金额(元)',
      dataIndex: 'received',
      key: 'received',
      align: "right",
      width: "5%",
      render: (text, record, index) => (record.received.toFixed(2))
    }, {
      title: '可用余额(元)',
      dataIndex: 'availableBalance',
      key: 'availableBalance',
      align: "right",
      width: "5%",
      render: (text, record, index) => (record.availableBalance.toFixed(2))
    }, {
      title: '支付方式',
      dataIndex: 'paymentType',
      key: 'paymentType',
      width: "5%",
      render: (text, record, index) => (record.paymentType === "alipay_pc_direct" ? "线上充值(支付宝)" : record.paymentType === "wx_pub_qr" ? "线上充值(微信)" : record.paymentType === "wx_lite" ? "小程序" : record.paymentType)
    }, {
      title: '支付时间',
      dataIndex: 'paymentTime',
      key: 'paymentTime',
      width: "5%",
      render: (text, record, index) => (moment(record.paymentTime).format("YYYY-MM-DD"))
    }, {
      title: '付款方',
      dataIndex: 'paymenter.name',
      key: 'paymenter.name',
      width: "5%",
    }, {
      title: '状态',
      dataIndex: 'auditStatus',
      key: 'auditStatus',
      width: "5%",
      render: (text, record) => (
        <span >
          {record.auditStatus == "NULL"
            ? '待审核'
            : record.auditStatus == "AUDIT_SUCCESS"
              ? '审核通过'
              : '审核未通过'}
        </span >
      )
    }, {
      title: '操作',
      key: 'handle',
      width: "5%",
      render: (text, record) => (
        <span>
          {record.auditStatus === "NULL" && record.receiptType !== "LWJ_RECEIPT" && showAuditButton ? <span><LwjButton
            tooltip="审核"
            type="primary"
            shape="circle"
            size="small"
            icon="check"
            onClick={() => onShowAudit(record)} /> <Divider type="vertical" /></span> : <a />}
          <LwjButton
            tooltip="查看"
            type="primary"
            shape="circle"
            size="small"
            icon="eye"
            onClick={() => onShowDetail(record)} />
        </span>
      )
    }
  ];

  return (
    <div>
      {/* <LwjTable {...tableProps} columns={columns} /> */}
      <LwjTable2
        {...tableProps}
        columns={columns}
      />
    </div>
  )
};

export default List
